import { PSAjaxControlImpl } from '../psajax-control-impl';
import { IPSCustomControl } from './ipscustom-control';
import { IPSSysPFPlugin } from '../../res/ipssys-pfplugin';

export class PSCustomControlImpl extends PSAjaxControlImpl implements IPSCustomControl {
  get customTag(): string {
    return this.M.customTag;
  }

  get customTag2(): string {
    return this.M.customTag2;
  }

  protected pssyspfplugin: IPSSysPFPlugin | null = null;

  getPSSysPFPlugin(): IPSSysPFPlugin | null {
    if (this.pssyspfplugin != null) return this.pssyspfplugin;
    const value = this.M.getPSSysPFPlugin;
    if (value == null) {
      return null;
    }
    this.pssyspfplugin = this.getPSModel4('res.IPSSysPFPlugin', value, 'getPSSysPFPlugin') as IPSSysPFPlugin;
    return this.pssyspfplugin;
  }

  get psSysPFPlugin(): IPSSysPFPlugin | null {
    return this.getPSSysPFPlugin();
  }

  getPSSysPFPluginMust(): IPSSysPFPlugin {
    const value = this.getPSSysPFPlugin();
    if (value == null) {
      throw new Error('未指定前端应用插件');
    }
    return value;
  }

  get predefinedType(): string {
    return this.M.predefinedType;
  }

  get cls(): string {
    return 'PSCustomControlImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'control.custom.IPSCustomControl') return true;
    return super.instanceof(cls);
  }
}
